﻿package com.wongoing.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wongoing.base.BaseServiceImpl;
import com.wongoing.base.PageResult;
import com.wongoing.sys.dao.SysRolePermissionDao;
import com.wongoing.sys.model.SysRolePermission;
import com.wongoing.sys.model.ext.SysRolePermissionExt;
import com.wongoing.sys.service.SysRolePermissionService;

@Service("sysRolePermissionService")
public class SysRolePermissionServiceImpl extends BaseServiceImpl<SysRolePermission> implements SysRolePermissionService {
	private SysRolePermissionDao dao;

	@Autowired
	public void setDao(SysRolePermissionDao dao) {
		super.setDao(dao);
		this.dao = dao;
	}
	
	/**
	 * 功能说明：获取权限分配页面最终显示数据
	 * 修改说明：
	 * @author zhenglibing
	 * @date 2017年10月13日 下午10:09:15
	 * @param pageResult 分页查询对象，包含查询条件
	 * @return 返回分页查询对象，包含页面数据
	 */
	public PageResult<SysRolePermissionExt> getRolePermissionListPageReuslt(PageResult<SysRolePermissionExt> pageResult) {
		pageResult.getParam().put("offset", pageResult.getPageSize() * (pageResult.getPageCurrent() - 1));
		pageResult.getParam().put("limit", pageResult.getPageSize());
		if (!"".equals(pageResult.getOrderField())) { pageResult.getParam().put("orderColumn", pageResult.getOrderField()); }
		pageResult.getParam().put("orderTurn", pageResult.getOrderDirection());
		List<SysRolePermissionExt> data = this.dao.getRolePermissionListPageByParam(pageResult.getParam());
		pageResult.setList(data);
		int totalSize = this.dao.countOfRolePermissionListPageByParam(pageResult.getParam());
		pageResult.setTotal(totalSize);
		return pageResult;
	}
}
